package com.lczyfz.wisdom.common.utils;

import redis.clients.jedis.Jedis;

import java.util.*;

/**
 * @author Lczy-Huang
 * @version 1.0
 * @classname RedisCURDUtil
 * @description redis 增删改查
 * @date 2018/11/12 14:56
 **/
public class RedisCURDUtil {

    private Jedis jedis;

    public void connectRedis() {
        jedis = RedisUtil.getJedis();
    }

    public Jedis getJedis() {
        return jedis;
    }

    public Set<String> hashMapGetKeys(String mapName){
        return jedis.hkeys(mapName);
    }

    public static void main(String args[]){
        RedisCURDUtil redisCURDUtil = new RedisCURDUtil();
        redisCURDUtil.connectRedis();
        //redisCURDUtil.getJedis().hdel("node1_disk_2018_11_12", "a");

        List<String> lists = redisCURDUtil.getJedis().hmget("node1_disk_2018_11_12","a");
        if(lists == null || lists.get(0)==null){
            System.out.println("aaa");
        }else{
            redisCURDUtil.getJedis().hdel("node1_disk_2018_11_12", "a");
        }
        Set sets = redisCURDUtil.hashMapGetKeys("node1_disk_2018_11_12");
        TreeSet<String> treeSet = new TreeSet<String>(sets);
//        Iterator iterator = treeSet.iterator();
//        while(iterator.hasNext()){
//            System.out.println("node1_disk_2018_11_12 "+String.valueOf(iterator.next())+" "+redisCURDUtil.getJedis().hmget("node1_disk_2018_11_12",String.valueOf(iterator.next())));
//        }
        System.out.println(treeSet);
    }
}
